/**           
 * Pawn.java
 * Auti i class epistrefi oles tis pithanes/nomimes kinisis tou Pawn.
 */
package gameStructure;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Vector;

/**
 * 
 * @author Stordopoulos Dimitris <stordop@csd.uoc.gr>
 */
public class Pawn extends  Piece{
    
    /**
     * 
     * @param pos Thesi tou Pawn.
     * @param clr Hroma tou Pawn.
     */
    public Pawn(Point pos, char clr){
        p=pos;
        clor=clr;
        value="Pawn";
        mov=true;
    }
    /**Rook
     * Epistrefi Oles tis pithanes/nomimes kinisis pou bori na kani to Pawn
     * apo tin singekrimeni thesi ( tou Point )
     * @param Board To Board me ta pionia pano sto Chess Board.
     * @return Vector pou periehi tis pithanes/epitreptes kinisis tou Pawn.
     */
    public Vector<Point> moves( ArrayList<ArrayList> Board, int c, int k, int cnt ){
        Vector<Point> ret=new Vector();
        c=1;
        for ( k=-1; k<2;k++){
            if (p.x+c<0 || p.x+c>7 || p.y+k<0 || p.y+k>7){
                if ( ((Piece)Board.get(p.x+c).get(p.y+k))==null || ((Piece)Board.get(p.x+c).get(p.y+k)).clor!=clor){
                    /**
                     * Periptosi pou to Pawn ine stin default arhiki thesi bori
                     * na metakinithi 2 tetragona pio brosta andi gia 1.
                     */ 
                    if (p.x==1 || p.x==6 && ( ((Piece)Board.get(p.x+2).get(p.y))==null || ((Piece)Board.get(p.x+2).get(p.y)).clor!=clor)) ret.addElement(((Piece)Board.get(p.x+2).get(p.y)).p);
                    if (!ret.contains(((Piece)Board.get(p.x+c).get(p.y+k)).p)) ret.addElement(((Piece)Board.get(p.x+c).get(p.y+k)).p);
                }
            }
        } 
        return ret;
    }
}